var ws = new WebSocket('ws://81.68.109.172:8888/ws');
var im;
var num = 10;

ws.onopen = function(){
    console.log("open");
    ws.send('WebSocket'); 
};
ws.onmessage = function(ev){
    im = ev;
    console.log(ev)
    console.log(ev.data);
    var object = JSON.parse(ev.data);
    if(object["p"] == 1){
        console.log(object["posx"],object["posy"]);
    }
    num ++;
};
ws.onclose = function(ev){
    console.log("close");
};
ws.onerror = function(ev){
    console.log("error");
};